import pyautogui
import time
import commonly_
import os.path
from _log import _log
def text_region(x, y):
    """
   便签应用文本区域
    :return:
    """
    logger.info("便签应用成功打开")
    logger.info("点击便签应用内部出入框")
    pyautogui.click(x + 23, y + 200)
    logger.info("输入文本测试内容")
    logger.info("粘贴输入的测试内容")
    pyautogui.hotkey("ctrl","v")
    pyautogui.click(x + 280, y + 20)
    pyautogui.click(x + 280, y + 20)


if __name__ == '__main__':
    pyautogui.moveTo(x=0, y=0, duration=0.5, tween=pyautogui.linear)
    pyautogui.FAILSAFE = False
    pyautogui.PAUSE = 1
    application = "便签"
    _log = _log(application)
    logfile = _log.return_logfile()
    logger = _log.return_logger()
    commonly = commonly_.Commonly(logfile)
    logger.info("*" * 20 + "当前测试程序：" + application + "*" * 20)
    while True:
        os.popen("ukui-notebook")
        time.sleep(3)
        logger.info("判断便签应用是否成功打开")
        x, y = commonly.test('Pictures/note_book/便签主页面.png')
        text_region(x, y)
        pyautogui.moveTo(0,0)
        time.sleep(1)

